<?php 
namespace Home\Controller;
class MyController extends CommonController{
	
	
	public function index(){
		$userinfo = session('_loginUser_home');
		$this->user = $userinfo; 
		$this->display();
	}
	
	public function person(){
		$this->user = session('_loginUser_home');
		$this->display();
	}
	
	public function history(){
		$uid = session('_loginUser_home')['uid'];
		$this->list = D('YgclOrder')->where(array('uid'=>$uid))->relation(true)->select();
		$this->display();
	}
	
	public function savesuggest(){
		if(IS_POST){
			$_POST['create_time'] = $_POST['update_time'] = Date('Y-m-d H:i:s');
			$m = D('YgclSuggest');
			$m->create($_POST);
			if($m->add()){
				$this->success('提交成功');
			}else{
				$this->error('提交失败');
			}
		}
	}
	
	public function sign(){
		$uid = session('_loginUser_home')['uid'];
		$cids = D('UsersDistrictRelation')->where(array('uid'=>$uid))->getField('cid',true);
		$m = D('YgclClass');
		$mm = D('YgclLesson');
		foreach ($cids as $key=>$cid){
			$classinfo = $m->where(array('id'=>$cid))->relation(true)->find();
			$data[$key]['title'] =  $classinfo['title'];
			$data[$key]['xiaoqu'] = $classinfo['district'];
			$data[$key]['lesson'] = $mm->where(array('cid'=>$cid))->relation(true)->order('listorder desc')->select();
		}
		$this->datas = $data;
		$this->display();
	}
	
	//签到列表
	public function signlist(){
		$this->display();
	}
	
	//获取签到信息
	public function getsigninfo(){
		$lid = I('lid');
		$page = I('page',1);
		$info = D('YgclSign')->where(array('lid'=>$lid))->order('id desc')->page($page,10)->select();
		count($info) < 10 ? $next = 'no':$next = 'yes';
		$data = array(
				'next'=>$next,
				'info'=>$info,
		);
		// 		$info['content'] = str_to_html($info['content']);
		$this->ajaxReturn($data);
	}
	
	public function signedit(){
		if(isset($_GET['id'])){
			$info = D('YgclSign')->find($_GET['id']);
			$this->info = $info;
				
			$lid = $info['lid'];
		}else{
			$lid = I('lid');
		}
		
		$this->lid = $lid;
		$students = R('Api/Lessonapi/get_students_by_now_xnid',array($lid));
		$this->uid = session('_loginUser_home')['uid'];
		$this->students = $students;
		$this->display();
	}

}
?>